import {IOpenScopePluginBase} from "./interfaces/pluginInterfaces/IOpenScopePluginBase";
import {IOpenScopePluginMenuItem} from "./interfaces/pluginInterfaces/IOpenScopePluginMenuItem";
import {IPluginInfo} from "./interfaces/pluginInterfaces/IPluginInfo";
import {IRadarRenderData} from "./interfaces/pluginInterfaces/IRenderData";

function init() {
    class ExamplePlugin implements IOpenScopePluginBase {
        onAcquireMenu(): Array<IOpenScopePluginMenuItem> {
            return [];
        }

        onAcquirePluginInformation(): IPluginInfo {
            return {
                pluginName: 'TopSky',
                authorName: 'OpenScope',
                description: '',
            };
        }

        onRadarFrame(ctx: CanvasRenderingContext2D, scaleIndex: number): void {
        }

        onRenderDataUpdate(_data: IRadarRenderData): void {
        }

        fetch = (_url: URL | Request | string, _init?: RequestInit): Promise<Response> => {
            throw new Error('There is no need for you to implement this member, any implementation will be overwrite during the plugin initialization process.');
        }

        getRenderDataInstance = (): IRadarRenderData => {
            throw new Error('There is no need for you to implement this member, any implementation will be overwrite during the plugin initialization process.');
        }

        invokeRadarRedraw = (): void => undefined;

        readBufferFile = (uri: string): Promise<Uint8Array> => {
            return Promise.reject(undefined);
        }

        readTextFile = (uri: string): Promise<string> => {
            return Promise.resolve("");
        }
        readCurFileToBase64 = (uri: string) => Promise.resolve("");

        setCurFileAsCursor = (uri: string) => Promise.resolve();

        onInitialized(workingDir: string): void {
            this.setCurFileAsCursor(`${workingDir}/TopSkyCursorCross.cur`).then(() => {
                console.log('cursor set');
            }).catch((e) => {
                console.error(e);
            });
        }
    }

    return new ExamplePlugin();
}